<?php
/**
 * Payroll Form
 *
 * @category   Cms
 * @package    Cms_Form
 */
class Cms_Form_Staff_Payroll_Form extends BIS_Form_Abstract
{
    public function init()
    {
        $this->addElementPrefixPath('Cms_Decorator',
                            	     APPLICATION_PATH . '/modules/cms/models/decorator/',
                            	    'decorator');
        
        $staffModel = new Cms_Model_Staff();
        $staffModelStaffs = $staffModel->getStaffs();
        
        $staffs = array();
        $staffs[NULL] = ' --- Select Staff Name --- ';
        foreach($staffModelStaffs as $staff) {
        	$staffs[$staff->staffId] = $staff->name;
        }
        
        $this->setMethod('post');
        $this->setAction('');

        $this->addElement('select', 'staffId', array(
            'label' => 'Staff Name',
            'required' => true,
            'multiOptions' => $staffs
        ));
        
        $this->addElement('text', 'basicSalary', array(
        		'label' => 'Basic Salary',
        		'size' => 20,
        		'required' => true,
        		'filters' => array('Null'),
        		'validators' => array('Float')
        ));
        
        $period = new BIS_Form_Element_Period('period');
        $period->setLabel('Period')->setRequired(true);
        $this->addElement($period); 
       
        $this->addElement('text', 'datePaid',array(
        		'label' => 'Date Paid',
        		'size' => 20,
        		'required' => true,
        		'validators' => array(array('Date', true, array('dd/MM/yyyy'))),
        		'filters' => array('StringTrim')
        ));
        
        $this->addElement('text', 'allowance', array(
        		'label' => 'Allowance',
        		'size' => 20,
        		'filters' => array('Null'),
        		'validators' => array('Float')
        ));
        
        $this->addElement('text', 'tax',array(
        		'label' => 'Tax %',
        		'size' => 5,
        		'filters' => array('Null'),
        		'validators' => array('Int')
        ));
        
        $this->setElementDecorators(array(
            'ViewHelper',
            'FormElementsErrors',
             array(array('data' => 'HtmlTag'),  array('tag' =>'td')),
              'FormElementsLabel',
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        ));

        $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'table', 'class'=> 'form')),
            'Form'
        ));

    }
}